home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2004 #9 / Amiga Plus CD - 2004 - No. 09.iso / amigaplus / tools / dev_libs / feelin040718 / sources / shade / gad.c < prev    next >
C/C++ Source or Header  |  2004-08-03  |  5KB  |  174 lines

  1. #include "Private.h"
  2. #include <intuition/gadgetclass.h>
  3.  
  4. #undef LocalObjectData
  5. #define LocalObjectData GAD_LocalObjectData
  6.  
  7. /*** Methods ***************************************************************/
  8.  
  9. ///Gad_New
  10. F_METHOD(APTR,Gad_New)
  11. {
  12.    struct LocalObjectData *LOD  = F_LOD(Class,Obj);
  13.    struct TagItem         *Tags = Msg;
  14.  
  15.    LOD -> AreaData = (FAreaData *) F_Get(Obj,FA_AreaData);
  16.  
  17.    if (LOD -> Type = GetTagData(FA_Gadget_Type,0,Tags))
  18.    {
  19.       if (F_SuperDo(Class,Obj,Method,
  20.                               FA_ChainToCycle,     FALSE,
  21.                               FA_InputMode,        (LOD -> Type == FV_GadgetType_Dragbar || LOD -> Type == FV_GadgetType_Size) ? FV_InputMode_None : FV_InputMode_Release,
  22.                               TAG_MORE,            Msg))
  23.       {
  24.          switch (LOD -> Type)
  25.          {
  26.             case FV_GadgetType_Close:     F_Do(Obj,FM_Notify,FA_Pressed,FALSE,FV_Notify_Window,FM_Set,2,FA_Window_CloseRequest,TRUE);  break;
  27.             case FV_GadgetType_Iconify:   F_Do(Obj,FM_Notify,FA_Pressed,FALSE,FV_Notify_Application,FM_Set,2,FA_Application_Sleep,TRUE); break;
  28.             case FV_GadgetType_Zoom:      F_Do(Obj,FM_Notify,FA_Pressed,FALSE,FV_Notify_Window,FM_Window_Zoom,1,FV_Window_Zoom_Toggle); break;
  29.             case FV_GadgetType_Depth:     F_Do(Obj,FM_Notify,FA_Pressed,FALSE,FV_Notify_Window,FM_Window_Depth,1,FV_Window_Depth_Toggle); break;
  30.          }
  31.          return Obj;
  32.       }
  33.    }
  34.    return NULL;
  35. }
  36. //+
  37. ///Gad_Setup
  38. F_METHOD(ULONG,Gad_Setup)
  39. {
  40.    struct LocalObjectData *LOD = F_LOD(Class,Obj);
  41.  
  42.    if (F_SUPERDO())
  43.    {
  44.       switch (LOD -> Type)
  45.       {
  46.          case FV_GadgetType_Dragbar:
  47.          {
  48.             if (F_Get(_win,FA_Window_GadDragbar))
  49.             {
  50.                if (!(LOD -> Gadget = NewObject(NULL,"buttongclass",GA_SysGType,GTYP_WDRAGGING,TAG_DONE))) return FALSE;
  51.  
  52.                LOD -> Prep[0] = (STRPTR) F_Do(_app,FM_Application_Resolve,"FP_Decorator_APreParse",NULL);
  53.                LOD -> Prep[1] = (STRPTR) F_Do(_app,FM_Application_Resolve,"FP_Decorator_IPreParse",NULL);
  54.  
  55.                LOD -> TDisplay = F_NewObj(FC_TextDisplay,
  56.                                           FA_TextDisplay_Font,     _font,
  57.                                           FA_TextDisplay_Shortcut, FALSE,
  58.                                           TAG_DONE);
  59.  
  60.                if (!F_Do(LOD -> TDisplay,FM_TextDisplay_Setup,_render))
  61.                {
  62.                   return FALSE;
  63.                }
  64.             }
  65.          }
  66.          break;
  67.  
  68.          case FV_GadgetType_Size:
  69.          {
  70.             if (!(LOD -> Gadget = NewObject(NULL,"buttongclass",GA_SysGType,GTYP_SIZING,TAG_DONE)))
  71.             {
  72.                return FALSE;
  73.             }
  74.          }
  75.          break;
  76.       }
  77.       return TRUE;
  78.    }
  79.    return FALSE;
  80. }
  81. //+
  82. ///Gad_Cleanup
  83. F_METHOD(void,Gad_Cleanup)
  84. {
  85.    struct LocalObjectData *LOD = F_LOD(Class,Obj);
  86.  
  87.    if (LOD -> Gadget)
  88.    {
  89.       DisposeObject(LOD -> Gadget);    LOD -> Gadget   = NULL;
  90.  
  91.       if (LOD -> TDisplay)
  92.       {
  93.          F_Do(LOD -> TDisplay,FM_TextDisplay_Cleanup);
  94.          F_DisposeObj(LOD -> TDisplay);   LOD -> TDisplay = NULL;
  95.       }
  96.    }
  97.    F_SUPERDO();
  98. }
  99. //+
  100. ///Gad_Show
  101. F_METHOD(ULONG,Gad_Show)
  102. {
  103.    struct LocalObjectData *LOD = F_LOD(Class,Obj);
  104.  
  105.    if (LOD -> Type == FV_GadgetType_Zoom)
  106.    {
  107.       F_Do(Obj,FM_ModifyHandler,IDCMP_MOUSEBUTTONS,0);
  108.    }
  109.  
  110.    if (LOD -> Gadget && _render)
  111.    {
  112.       struct Window *osw = (APTR) F_Get(_win,FA_Window);
  113.  
  114.       AddGadget(osw,LOD -> Gadget,-1);
  115.    }
  116.    return F_SUPERDO();
  117. }
  118. //+
  119. ///Gad_Hide
  120. F_METHOD(ULONG,Gad_Hide)
  121. {
  122.    struct LocalObjectData *LOD = F_LOD(Class,Obj);
  123.  
  124.    if (LOD -> Type == FV_GadgetType_Zoom)
  125.    {
  126.       F_Do(Obj,FM_ModifyHandler,0,IDCMP_MOUSEBUTTONS);
  127.    }
  128.  
  129.    if (LOD -> Gadget && _render)
  130.    {
  131.       struct Window *osw = (APTR) F_Get(_win,FA_Window);
  132.  
  133.       RemoveGadget(osw,LOD -> Gadget);
  134.    }
  135.    return F_SUPERDO();
  136. }
  137. //+
  138. ///Gad_Layout
  139. F_METHOD(void,Gad_Layout)
  140. {
  141.    struct LocalObjectData *LOD = F_LOD(Class,Obj);
  142.  
  143.    if (LOD -> Gadget)
  144.    {
  145.       SetAttrs(LOD -> Gadget,GA_Left,     _x,
  146.                              GA_Top,      _y,
  147.                              GA_Width,    _w,
  148.                              GA_Height,   _h, TAG_DONE);
  149.    }
  150.    F_SUPERDO();
  151. }
  152. //+
  153. ///Gad_HandleEvent
  154. F_METHODM(ULONG,Gad_HandleEvent,FS_HandleEvent)
  155. {
  156. //   struct LocalObjectData *LOD = F_LOD(Class,Obj);
  157. /*
  158.    if (LOD -> Type == FV_GadgetType_Zoom &&
  159.        Msg -> FEv -> Class == IDCMP_MOUSEBUTTONS)
  160.    {
  161. /*
  162.       if (Msg -> FEv -> Code == MENUUP)
  163.  
  164.       _inside(FEv -> MouseX,_x,_x + _w - 1) &&
  165.                    _inside(FEv -> MouseY,_y,_y + _h - 1))
  166. */
  167.       F_Log(0,"MOUSE BUTTON");
  168.    }
  169. */
  170.    return F_SUPERDO();
  171. }
  172. //+
  173.  
  174.